package br.urca.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name = "Protocolo")
public class Protocolo implements Serializable {

	private static final long serialVersionUID = 1L;
	
	@EmbeddedId
	private ProtocoloPK id;
	
	@Column(name = "DtEntrada")
	@Temporal(TemporalType.TIMESTAMP)
	private Date dataEntrada;
	
	@Column(name = "Nume", columnDefinition = "VARCHAR(15)")
	private String nume;
	
	@Column(name = "Origem", columnDefinition = "VARCHAR(1)")
	private String origem;
	
	@Column(name = "FunRes", columnDefinition = "VARCHAR(2)")
	private String funRes;
	
	public Protocolo() { }
	
	public Protocolo(ProtocoloPK id, Date dataEntrada, String nume,
			String origem, String funRes) {
		super();
		this.id = id;
		this.dataEntrada = dataEntrada;
		this.nume = nume;
		this.origem = origem;
		this.funRes = funRes;
	}

	public ProtocoloPK getId() {
		return id;
	}

	public void setId(ProtocoloPK id) {
		this.id = id;
	}

	public Date getDataEntrada() {
		return dataEntrada;
	}

	public void setDataEntrada(Date dataEntrada) {
		this.dataEntrada = dataEntrada;
	}

	public String getNume() {
		return nume;
	}

	public void setNume(String nume) {
		this.nume = nume;
	}

	public String getOrigem() {
		return origem;
	}

	public void setOrigem(String origem) {
		this.origem = origem;
	}

	public String getFunRes() {
		return funRes;
	}

	public void setFunRes(String funRes) {
		this.funRes = funRes;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((dataEntrada == null) ? 0 : dataEntrada.hashCode());
		result = prime * result + ((funRes == null) ? 0 : funRes.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((nume == null) ? 0 : nume.hashCode());
		result = prime * result + ((origem == null) ? 0 : origem.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Protocolo other = (Protocolo) obj;
		if (dataEntrada == null) {
			if (other.dataEntrada != null)
				return false;
		} else if (!dataEntrada.equals(other.dataEntrada))
			return false;
		if (funRes == null) {
			if (other.funRes != null)
				return false;
		} else if (!funRes.equals(other.funRes))
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (nume == null) {
			if (other.nume != null)
				return false;
		} else if (!nume.equals(other.nume))
			return false;
		if (origem == null) {
			if (other.origem != null)
				return false;
		} else if (!origem.equals(other.origem))
			return false;
		return true;
	}
	
	

}
